package com.tgu.home_action.pojo;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;


import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.Map;

@Data
@ApiModel(description = "志愿者用户")
public class Volunteer {
    @ApiModelProperty("志愿者ID")
    private Integer id;


    /**
     * 昵称
     */
    @ApiModelProperty("昵称")
    private String nickName;
    /**
     * 头像
     */
    @ApiModelProperty("头像")
    private String avatarUrl;

    @ApiModelProperty("手机号")
    private String phone;


    @JsonIgnore
    private String openid;
    /**
     * 账号状态，0为被封禁，1为正常，2为正在申请解封
     */

    @Min(value = 1, message = "state只能是1或2", groups = {VolunteerInformation.update.class})
    @Max(value = 2, message = "state只能是1或2", groups = {VolunteerInformation.update.class})
    @ApiModelProperty("用户状态")
    private Short state;

    @ApiModelProperty("位置所在经度")
    private Double longitude;

    @ApiModelProperty("位置所在纬度")
    private Double latitude;

    @ApiModelProperty("是否在线")
    private Short online;

    @ApiModelProperty("志愿者信息")
    private VolunteerInformation volunteerInformation;

    @ApiModelProperty("志愿者的案件信息")
    private VolunteerCase volunteerCase;

    public Volunteer() {
    }

    public Volunteer(Integer id) {
        this.id = id;
    }


    /**
     * 比较头像和昵称是否相同
     *
     * @param volunteer：一号志愿者
     * @param volunteerUser：二号志愿者
     * @return boolean
     */
    public static boolean compareUserinfo(Volunteer volunteer, Volunteer volunteerUser) {
        return volunteer.avatarUrl.equals(volunteerUser.avatarUrl) && volunteer.nickName.equals(volunteerUser.nickName);
    }

    /**
     * 设置微信获取的用户信息
     *
     * @param data：微信用户信息
     */
    public void setUserinfo(Map<String, Object> data) {
        this.nickName = (String) data.get("nickName");
        this.avatarUrl = (String) data.get("avatarUrl");
    }

    public interface userinfo {
    }
}
